```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式系统架构指南 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight::after {
            content: '';
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(110, 142, 251, 0.3);
            z-index: -1;
            transition: height 0.3s ease;
        }
        .highlight:hover::after {
            height: 50%;
        }
        .section-divider {
            border: none;
            height: 1px;
            background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(167,119,227,0.5) 50%, rgba(0,0,0,0) 100%);
        }
        .dropcap::first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.85;
            margin: 0.1em 0.15em 0 0;
            font-weight: 700;
            color: #6e8efb;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-24 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="serif text-4xl sm:text-5xl md:text-6xl font-bold leading-tight mb-6">
                分布式系统架构指南
            </h1>
            <p class="text-xl sm:text-2xl max-w-3xl mx-auto opacity-90 mb-8">
                构建高性能、高可用的现代分布式系统
            </p>
            <div class="flex justify-center space-x-4">
                <a href="#overview" class="px-6 py-3 bg-white text-indigo-700 font-semibold rounded-lg hover:bg-opacity-90 transition duration-300">
                    <i class="fas fa-book-open mr-2"></i>开始阅读
                </a>
                <a href="#architecture" class="px-6 py-3 bg-transparent border-2 border-white text-white font-semibold rounded-lg hover:bg-white hover:bg-opacity-10 transition duration-300">
                    <i class="fas fa-project-diagram mr-2"></i>架构模式
                </a>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Overview Section -->
        <section id="overview" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-sitemap text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">1. 分布式系统概述</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md p-8 mb-8 card-hover">
                <p class="text-lg dropcap">
                    分布式系统是一组通过网络互相通信、协同工作以完成特定任务的计算机集合。它广泛应用于大规模业务系统，如电商、金融、社交平台等，能够提供更高的可扩展性、可用性和容错性。
                </p>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="font-bold text-xl mb-4 text-indigo-600">
                        <i class="fas fa-bolt mr-2"></i>主要优势
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>横向扩展能力，提升系统吞吐量</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>高可用性，单点故障不影响整体</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>地理分布，降低延迟提升用户体验</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="font-bold text-xl mb-4 text-indigo-600">
                        <i class="fas fa-exclamation-triangle mr-2"></i>应用场景
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-shopping-cart text-purple-500 mt-1 mr-2"></i>
                            <span>电商平台 & 秒杀系统</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-comments text-blue-500 mt-1 mr-2"></i>
                            <span>社交媒体 & 即时通讯</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-cloud text-teal-500 mt-1 mr-2"></i>
                            <span>云计算 & 大数据处理</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <hr class="section-divider my-16">

        <!-- Challenges Section -->
        <section id="challenges" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-puzzle-piece text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">2. 分布式系统的核心挑战</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">2.1 数据一致性问题</h3>
                        <p class="mb-4">
                            在分布式系统中，不同节点可能存储相同的数据副本，但由于网络延迟或节点故障，数据可能不一致。
                        </p>
                        <div class="bg-gray-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-gray-700">解决方案:</h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <span class="inline-flex items-center justify-center h-6 w-6 rounded-full bg-indigo-100 text-indigo-800 font-bold mr-2">1</span>
                                    <span><strong>强一致性</strong> (Strong Consistency)</span>
                                </li>
                                <li class="flex items-start">
                                    <span class="inline-flex items-center justify-center h-6 w-6 rounded-full bg-indigo-100 text-indigo-800 font-bold mr-2">2</span>
                                    <span><strong>最终一致性</strong> (Eventual Consistency)</span>
                                </li>
                                <li class="flex items-start">
                                    <span class="inline-flex items-center justify-center h-6 w-6 rounded-full bg-indigo-100 text-indigo-800 font-bold mr-2">3</span>
                                    <span><strong>弱一致性</strong> (Weak Consistency)</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">2.2 网络分区与容错性</h3>
                        <p class="mb-4">
                            网络分区意味着某些节点可能暂时无法通信，系统需要设计容错机制，如 <strong>CAP 定理</strong> 所述。
                        </p>
                        <div class="mermaid bg-gray-50 rounded-lg p-4">
                            graph LR
                            A[CAP定理] --> B[一致性 Consistency]
                            A --> C[可用性 Availability]
                            A --> D[分区容错性 Partition Tolerance]
                            style B fill:#6e8efb,color:#fff
                            style C fill:#a777e3,color:#fff
                            style D fill:#4fd1c5,color:#fff
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover mb-8">
                <div class="p-6">
                    <h3 class="font-bold text-xl mb-4 text-indigo-600">2.3 负载均衡</h3>
                    <p class="mb-4">
                        分布式系统通常需要多个节点共同处理请求，因此需要 <strong>负载均衡策略</strong>。
                    </p>
                    <div class="grid md:grid-cols-3 gap-6">
                        <div class="bg-indigo-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-indigo-700">
                                <i class="fas fa-sync-alt mr-2"></i>轮询
                            </h4>
                            <p class="text-sm">(Round Robin)</p>
                            <p class="mt-2 text-gray-700 text-sm">按顺序将请求分配给服务器，确保每个服务器得到相等的请求量。</p>
                        </div>
                        <div class="bg-purple-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-purple-700">
                                <i class="fas fa-random mr-2"></i>权重随机
                            </h4>
                            <p class="text-sm">(Weighted Random)</p>
                            <p class="mt-2 text-gray-700 text-sm">根据服务器性能分配随机权重，高性能服务器处理更多请求。</p>
                        </div>
                        <div class="bg-teal-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-teal-700">
                                <i class="fas fa-project-diagram mr-2"></i>最小连接数
                            </h4>
                            <p class="text-sm">(Least Connections)</p>
                            <p class="mt-2 text-gray-700 text-sm">将新请求分配给当前连接数最少的服务器，实现动态平衡。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <hr class="section-divider my-16">

        <!-- Architecture Section -->
        <section id="architecture" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-layer-group text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">3. 分布式架构模式</h2>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 card-hover">
                <div class="p-6">
                    <h3 class="font-bold text-xl mb-6 text-indigo-600">3.1 单体架构 vs. 微服务架构</h3>
                    <div class="mermaid bg-gray-50 rounded-lg p-4 mb-6">
                        flowchart LR
                        subgraph 单体架构
                        A[应用] --> B[数据库]
                        end
                        subgraph 微服务架构
                        C[服务A] --> D[数据库A]
                        E[服务B] --> F[数据库B]
                        G[服务C] --> H[数据库C]
                        end
                        style A fill:#6e8efb,color:#fff
                        style C fill:#a777e3,color:#fff
                        style E fill:#a777e3,color:#fff
                        style G fill:#a777e3,color:#fff
                    </div>
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="font-semibold text-lg mb-2 text-gray-700">
                                <i class="fas fa-cube mr-2 text-indigo-500"></i>单体架构
                            </h4>
                            <ul class="space-y-2 text-sm">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>所有功能模块封装在一个应用内</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>部署简单，开发测试便捷</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                    <span>难以扩展，技术栈单一</span>
                                </li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2 text-gray-700">
                                <i class="fas fa-puzzle-piece mr-2 text-purple-500"></i>微服务架构
                            </h4>
                            <ul class="space-y-2 text-sm">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>将应用拆分为多个独立部署的小服务</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                    <span>每个服务具备独立的数据库和业务逻辑</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                    <span>分布式复杂度高，运维难度大</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">3.2 事件驱动架构</h3>
                        <p class="mb-4">
                            基于消息队列（Kafka、RabbitMQ、RocketMQ），通过事件传递进行解耦，提高系统的异步处理能力。
                        </p>
                        <div class="mermaid bg-gray-50 rounded-lg p-4">
                            sequenceDiagram
                            参与者 Producer->>+MQ: 发布事件
                            MQ->>+Consumer1: 消费事件
                            MQ->>+Consumer2: 消费事件
                            Consumer1-->>-MQ: 确认处理
                            Consumer2-->>-MQ: 确认处理
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">3.3 Serverless 架构</h3>
                        <p class="mb-4">
                            Serverless（无服务器架构）是一种按需分配资源的架构模式，常用于 <strong>函数计算（FaaS）</strong>。
                        </p>
                        <div class="grid grid-cols-2 gap-4">
                            <div class="bg-blue-50 rounded-lg p-3">
                                <h4 class="font-semibold text-sm mb-1 text-blue-700">优点</h4>
                                <ul class="text-xs space-y-1">
                                    <li>• 无需管理基础设施</li>
                                    <li>• 按使用量计费</li>
                                    <li>• 自动扩展</li>
                                </ul>
                            </div>
                            <div class="bg-orange-50 rounded-lg p-3">
                                <h4 class="font-semibold text-sm mb-1 text-orange-700">缺点</h4>
                                <ul class="text-xs space-y-1">
                                    <li>• 冷启动问题</li>
                                    <li>• 调试困难</li>
                                    <li>• 厂商锁定</li>
                                </ul>
                            </div>
                        </div>
                        <div class="mt-4 bg-gray-50 rounded-lg p-3 text-sm">
                            <p class="text-gray-700"><strong>典型应用:</strong> 数据处理、定时任务、API后端、IoT数据处理</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Data Management Section -->
        <section id="data" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-database text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">4. 分布式数据管理</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">4.1 分布式存储</h3>
                        <div class="grid grid-cols-2 gap-4">
                            <div class="bg-indigo-50 rounded-lg p-4">
                                <h4 class="font-semibold mb-2 text-indigo-700">
                                    <i class="fas fa-share-alt mr-2"></i>分片
                                </h4>
                                <p class="text-sm">(Sharding)</p>
                                <p class="mt-2 text-gray-700 text-sm">将数据拆分存储在不同节点，提高读写性能。</p>
                            </div>
                            <div class="bg-purple-50 rounded-lg p-4">
                                <h4 class="font-semibold mb-2 text-purple-700">
                                    <i class="fas fa-copy mr-2"></i>副本
                                </h4>
                                <p class="text-sm">(Replication)</p>
                                <p class="mt-2 text-gray-700 text-sm">复制数据到多个节点，提高可用性和可靠性。</p>
                            </div>
                        </div>
                        <div class="mt-4 bg-gray-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-gray-700">经典实现</h4>
                            <div class="flex flex-wrap gap-2">
                                <span class="px-3 py-1 bg-blue-100 text-blue-800 rounded-full text-sm">MongoDB</span>
                                <span class="px-3 py-1 bg-green-100 text-green-800 rounded-full text-sm">Cassandra</span>
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">HBase</span>
                                <span class="px-3 py-1 bg-yellow-100 text-yellow-800 rounded-full text-sm">MySQL分片</span>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">4.2 分布式缓存</h3>
                        <p class="mb-4">
                            分布式缓存（Redis、Memcached）用于加速数据访问，减轻数据库压力。
                        </p>
                        <div class="grid grid-cols-2 gap-4 mb-4">
                            <div class="bg-red-50 rounded-lg p-3">
                                <h4 class="font-semibold text-sm mb-1 text-red-700">Redis</h4>
                                <ul class="text-xs space-y-1">
                                    <li>• 支持多种数据结构</li>
                                    <li>• 持久化选项</li>
                                    <li>• 集群模式</li>
                                </ul>
                            </div>
                            <div class="bg-orange-50 rounded-lg p-3">
                                <h4 class="font-semibold text-sm mb-1 text-orange-700">Memcached</h4>
                                <ul class="text-xs space-y-1">
                                    <li>• 简单键值存储</li>
                                    <li>• 内存效率高</li>
                                    <li>• 多线程</li>
                                </ul>
                            </div>
                        </div>
                        <div class="bg-gray-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-gray-700">缓存策略</h4>
                            <div class="flex flex-wrap gap-2">
                                <span class="px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full text-sm">LRU</span>
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">LFU</span>
                                <span class="px-3 py-1 bg-teal-100 text-teal-800 rounded-full text-sm">FIFO</span>
                                <span class="px-3 py-1 bg-pink-100 text-pink-800 rounded-full text-sm">TTL</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <hr class="section-divider my-16">

        <!-- Consistency Solutions Section -->
        <section id="consistency" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-handshake text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">5. 分布式一致性解决方案</h2>
            </div>

            <div class="grid md:grid-cols-3 gap-8 mb-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">
                            <i class="fas fa-step-forward mr-2"></i>5.1 2PC
                        </h3>
                        <p class="mb-4 text-sm">
                            两阶段提交(2PC)保证分布式事务的 ACID 特性，分为"准备阶段"和"提交阶段"。
                        </p>
                        <div class="mermaid bg-gray-50 rounded-lg p-4 text-xs">
                            sequenceDiagram
                            协调者->>参与者1: 准备请求
                            协调者->>参与者2: 准备请求
                            参与者1-->>协调者: 准备就绪
                            参与者2-->>协调者: 准备就绪
                            协调者->>参与者1: 提交请求
                            协调者->>参与者2: 提交请求
                            参与者1-->>协调者: 确认提交
                            参与者2-->>协调者: 确认提交
                        </div>
                        <div class="mt-4 bg-gray-100 rounded-lg p-3">
                            <p class="text-xs text-gray-700"><strong>缺点:</strong> 同步阻塞、单点故障、数据不一致风险</p>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">
                            <i class="fas fa-exchange-alt mr-2"></i>5.2 TCC
                        </h3>
                        <p class="mb-4 text-sm">
                            TCC(Try-Confirm-Cancel)适用于业务事务控制，包含三个关键阶段。
                        </p>
                        <div class="grid grid-cols-3 gap-2 mb-4">
                            <div class="bg-yellow-50 rounded-lg p-2 text-center">
                                <div class="bg-yellow-100 rounded-full h-8 w-8 flex items-center justify-center mx-auto mb-1">
                                    <span class="font-bold text-yellow-800">1</span>
                                </div>
                                <p class="text-xs font-semibold text-yellow-800">Try</p>
                                <p class="text-xs">预留资源</p>
                            </div>
                            <div class="bg-green-50 rounded-lg p-2 text-center">
                                <div class="bg-green-100 rounded-full h-8 w-8 flex items-center justify-center mx-auto mb-1">
                                    <span class="font-bold text-green-800">2</span>
                                </div>
                                <p class="text-xs font-semibold text-green-800">Confirm</p>
                                <p class="text-xs">执行事务</p>
                            </div>
                            <div class="bg-red-50 rounded-lg p-2 text-center">
                                <div class="bg-red-100 rounded-full h-8 w-8 flex items-center justify-center mx-auto mb-1">
                                    <span class="font-bold text-red-800">3</span>
                                </div>
                                <p class="text-xs font-semibold text-red-800">Cancel</p>
                                <p class="text-xs">回滚事务</p>
                            </div>
                        </div>
                        <div class="mt-2 bg-gray-100 rounded-lg p-3">
                            <p class="text-xs text-gray-700"><strong>适用场景:</strong> 电商、金融等高一致性要求的业务</p>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">
                            <i class="fas fa-undo-alt mr-2"></i>5.3 Saga
                        </h3>
                        <p class="mb-4 text-sm">
                            Saga采用补偿机制，每个事务都有相应的补偿操作，适用于微服务架构。
                        </p>
                        <div class="mermaid bg-gray-50 rounded-lg p-4 text-xs">
                            graph LR
                            A[订单服务:创建订单] --> B[库存服务:扣减库存]
                            B --> C[支付服务:扣款]
                            C --> D[订单服务:确认订单]
                            D -->|失败| E[支付服务:退款]
                            E --> F[库存服务:恢复库存]
                            F --> G[订单服务:取消订单]
                        </div>
                        <div class="mt-4 bg-gray-100 rounded-lg p-3">
                            <p class="text-xs text-gray-700"><strong>优势:</strong> 长事务处理、服务解耦</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Governance Section -->
        <section id="governance" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-network-wired text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">6. 分布式服务治理</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">6.1 服务发现与注册中心</h3>
                        <p class="mb-4">
                            通过注册中心管理微服务实例，实现动态服务发现。
                        </p>
                        <div class="grid grid-cols-3 gap-4 text-center">
                            <div class="bg-blue-50 rounded-lg p-3">
                                <i class="fas fa-cloud text-3xl text-blue-500 mb-2"></i>
                                <h4 class="font-semibold text-sm text-blue-700">Eureka</h4>
                                <p class="text-xs">(Netflix)</p>
                            </div>
                            <div class="bg-green-50 rounded-lg p-3">
                                <i class="fas fa-compass text-3xl text-green-500 mb-2"></i>
                                <h4 class="font-semibold text-sm text-green-700">Consul</h4>
                                <p class="text-xs">(HashiCorp)</p>
                            </div>
                            <div class="bg-purple-50 rounded-lg p-3">
                                <i class="fas fa-star text-3xl text-purple-500 mb-2"></i>
                                <h4 class="font-semibold text-sm text-purple-700">Nacos</h4>
                                <p class="text-xs">(Alibaba)</p>
                            </div>
                        </div>
                        <div class="mt-4 bg-gray-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-gray-700">核心功能</h4>
                            <ul class="grid grid-cols-2 gap-2 text-sm">
                                <li class="flex items-center">
                                    <i class="fas fa-check text-green-500 mr-2"></i>服务注册
                                </li>
                                <li class="flex items-center">
                                    <i class="fas fa-check text-green-500 mr-2"></i>健康检查
                                </li>
                                <li class="flex items-center">
                                    <i class="fas fa-check text-green-500 mr-2"></i>负载均衡
                                </li>
                                <li class="flex items-center">
                                    <i class="fas fa-check text-green-500 mr-2"></i>配置管理
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">6.2 限流与熔断</h3>
                        <div class="grid md:grid-cols-2 gap-4 mb-4">
                            <div class="bg-red-50 rounded-lg p-4">
                                <h4 class="font-semibold mb-2 text-red-700">
                                    <i class="fas fa-tachometer-alt mr-2"></i>限流
                                </h4>
                                <p class="text-sm">(Rate Limiting)</p>
                                <p class="mt-2 text-gray-700 text-sm">防止单个服务被过载，保障系统稳定性。</p>
                                <div class="mt-3">
                                    <h5 class="text-xs font-semibold mb-1">常见算法:</h5>
                                    <div class="flex flex-wrap gap-1">
                                        <span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs">令牌桶</span>
                                        <span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs">漏桶</span>
                                        <span class="px-2 py-1 bg-red-100 text-red-800 rounded-full text-xs">计数器</span>
                                    </div>
                                </div>
                            </div>
                            <div class="bg-orange-50 rounded-lg p-4">
                                <h4 class="font-semibold mb-2 text-orange-700">
                                    <i class="fas fa-plug mr-2"></i>熔断
                                </h4>
                                <p class="text-sm">(Circuit Breaker)</p>
                                <p class="mt-2 text-gray-700 text-sm">快速失败机制，避免级联故障。</p>
                                <div class="mt-3">
                                    <h5 class="text-xs font-semibold mb-1">状态转换:</h5>
                                    <div class="mermaid text-xs">
                                        stateDiagram-v2
                                        [*] --> Closed
                                        Closed --> Open: 失败阈值
                                        Open --> HalfOpen: 超时
                                        HalfOpen --> Closed: 成功
                                        HalfOpen --> Open: 失败
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="bg-gray-50 rounded-lg p-4">
                            <h4 class="font-semibold mb-2 text-gray-700">实现方案</h4>
                            <div class="flex flex-wrap gap-2">
                                <span class="px-3 py-1 bg-blue-100 text-blue-800 rounded-full text-sm">Hystrix</span>
                                <span class="px-3 py-1 bg-green-100 text-green-800 rounded-full text-sm">Sentinel</span>
                                <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">Resilience4j</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <hr class="section-divider my-16">

        <!-- Monitoring Section -->
        <section id="monitoring" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-chart-line text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">7. 分布式日志与监控</h2>
            </div>

            <div class="grid md:grid-cols-3 gap-8 mb-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">7.1 日志收集</h3>
                        <p class="mb-4">
                            分布式系统中，日志可通过 <strong>ELK</strong> 栈进行统一收集和分析。
                        </p>
                        <div class="grid grid-cols-3 gap-2 text-center mb-4">
                            <div class="bg-blue-50 rounded-lg p-2">
                                <i class="fas fa-search text-2xl text-blue-500 mb-1"></i>
                                <p class="text-xs font-semibold">Elasticsearch</p>
                            </div>
                            <div class="bg-orange-50 rounded-lg p-2">
                                <i class="fas fa-stream text-2xl text-orange-500 mb-1"></i>
                                <p class="text-xs font-semibold">Logstash</p>
                            </div>
                            <div class="bg-purple-50 rounded-lg p-2">
                                <i class="fas fa-chart-bar text-2xl text-purple-500 mb-1"></i>
                                <p class="text-xs font-semibold">Kibana</p>
                            </div>
                        </div>
                        <div class="bg-gray-50 rounded-lg p-3">
                            <h4 class="font-semibold text-sm mb-1 text-gray-700">优势</h4>
                            <ul class="text-xs space-y-1">
                                <li>• 集中式日志管理</li>
                                <li>• 强大的搜索能力</li>
                                <li>• 可视化分析</li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">7.2 链路追踪</h3>
                        <p class="mb-4">
                            分布式请求链路追踪，可视化服务调用关系。
                        </p>
                        <div class="grid grid-cols-2 gap-4 mb-4">
                            <div class="bg-green-50 rounded-lg p-3 text-center">
                                <i class="fas fa-map-marked-alt text-3xl text-green-500 mb-2"></i>
                                <h4 class="font-semibold text-sm text-green-700">Zipkin</h4>
                                <p class="text-xs">轻量级分布式追踪系统</p>
                            </div>
                            <div class="bg-blue-50 rounded-lg p-3 text-center">
                                <i class="fas fa-mountain text-3xl text-blue-500 mb-2"></i>
                                <h4 class="font-semibold text-sm text-blue-700">SkyWalking</h4>
                                <p class="text-xs">APM监控系统</p>
                            </div>
                        </div>
                        <div class="bg-gray-50 rounded-lg p-3">
                            <h4 class="font-semibold text-sm mb-1 text-gray-700">追踪数据</h4>
                            <ul class="text-xs space-y-1">
                                <li>• 调用链路可视化</li>
                                <li>• 性能瓶颈分析</li>
                                <li>• 异常请求追踪</li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">7.3 指标监控</h3>
                        <p class="mb-4">
                            通过 <strong>Prometheus + Grafana</strong> 进行系统指标监控和告警。
                        </p>
                        <div class="grid grid-cols-2 gap-4 mb-4">
                            <div class="bg-red-50 rounded-lg p-3 text-center">
                                <i class="fas fa-database text-3xl text-red-500 mb-2"></i>
                                <h4 class="font-semibold text-sm text-red-700">Prometheus</h4>
                                <p class="text-xs">时序数据库</p>
                            </div>
                            <div class="bg-purple-50 rounded-lg p-3 text-center">
                                <i class="fas fa-chart-pie text-3xl text-purple-500 mb-2"></i>
                                <h4 class="font-semibold text-sm text-purple-700">Grafana</h4>
                                <p class="text-xs">可视化仪表盘</p>
                            </div>
                        </div>
                        <div class="bg-gray-50 rounded-lg p-3">
                            <h4 class="font-semibold text-sm mb-1 text-gray-700">监控指标</h4>
                            <ul class="text-xs space-y-1">
                                <li>• 系统资源使用率</li>
                                <li>• 服务响应时间</li>
                                <li>• 请求成功率</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Best Practices Section -->
        <section id="practices" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="flex-shrink-0 bg-indigo-500 rounded-full p-3 mr-4">
                    <i class="fas fa-medal text-white text-xl"></i>
                </div>
                <h2 class="serif text-3xl font-bold text-gray-800">8. 分布式架构最佳实践</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">8.1 设计原则</h3>
                        <div class="space-y-4">
                            <div class="flex items-start">
                                <div class="flex-shrink-0 bg-indigo-100 rounded-full p-2 mr-4">
                                    <i class="fas fa-check-circle text-indigo-600"></i>
                                </div>
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-1">高可用</h4>
                                    <p class="text-sm text-gray-700">多副本存储，服务降级策略，避免单点故障。</p>
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 bg-green-100 rounded-full p-2 mr-4">
                                    <i class="fas fa-bolt text-green-600"></i>
                                </div>
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-1">高性能</h4>
                                    <p class="text-sm text-gray-700">合理使用缓存，优化数据库查询，异步处理。</p>
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 bg-purple-100 rounded-full p-2 mr-4">
                                    <i class="fas fa-expand-arrows-alt text-purple-600"></i>
                                </div>
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-1">可扩展</h4>
                                    <p class="text-sm text-gray-700">采用无状态服务设计，支持动态水平扩展。</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 text-indigo-600">8.2 性能优化</h3>
                        <div class="space-y-4">
                            <div class="flex items-start">
                                <div class="flex-shrink-0 bg-blue-100 rounded-full p-2 mr-4">
                                    <i class="fas fa-clock text-blue-600"></i>
                                </div>
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-1">异步处理</h4>
                                    <p class="text-sm text-gray-700">减少主线程阻塞，提高系统吞吐量，如消息队列。</p>
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 bg-yellow-100 rounded-full p-2 mr-4">
                                    <i class="fas fa-boxes text-yellow-600"></i>
                                </div>
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-1">批量请求</h4>
                                    <p class="text-sm text-gray-700">合并远程调用，减少网络开销，提升性能。</p>
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 bg-red-100 rounded-full p-2 mr-4">
                                    <i class="fas fa-memory text-red-600"></i>
                                </div>
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-1">缓存策略</h4>
                                    <p class="text-sm text-gray-700">多级缓存设计，合理设置过期时间，减轻数据库压力。</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                <div class="p-6">
                    <h3 class="font-bold text-xl mb-6 text-indigo-600">分布式架构技术全景图</h3>
                    <div class="mermaid bg-gray-50 rounded-lg p-4">
                        mindmap
                            root((分布式系统))
                                架构模式
                                    微服务
                                    事件驱动
                                    Serverless
                                数据管理
                                    分片
                                    副本
                                    分布式事务
                                服务治理
                                    服务发现
                                    熔断限流
                                    配置中心
                                监控运维
                                    日志收集
                                    链路追踪
                                    指标监控
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-sm">探索技术奥秘，分享知识精华</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-400 hover:text-white transition duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-800 text-center text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeCSS: `
                .node rect {
                    fill: #fff;
                    stroke: #6e8efb;
                    stroke-width: 2px;
                }
                .edgePath path {
                    stroke: #a777e3;
                    stroke-width: 2px;
                }
                .cluster rect {
                    fill: #f0f4ff;
                    stroke: #a777e3;
                    stroke-width: 1px;
                    rx: 5;
                    ry: 5;
                }
            `
        });
    </script>
</body>
</html>
```